<template>
  <div>
    <van-nav-bar  class="vue_bar">
      <template #title>
        <van-cell-group>
          <van-field
            v-model="value"
            placeholder="请输入小区或地址"
            style="width: 150px"
            @keyup.enter="searchHouse"
          />
        </van-cell-group>
      </template>
      <template #right>
        <span @click="$router.go(-1)">取消</span>
      </template>
    </van-nav-bar>

    <h4
      v-for="(item, index) in renderlist"
      :key="index"
      @click="
        $router.push({
          name: 'publishHouse',
          query: { text: item.communityName ,
          community:item.community}
        })
      "
    >
      {{ item.communityName }}
    </h4>
  </div>
</template>

<script>
import { getHouse } from '@/api/citylist'
export default {
  name: 'Community',
  props: {},
  data () {
    return {
      value: '',
      renderlist: []
    }
  },
  methods: {
    async searchHouse () {
      const id = localStorage.getItem('id')
      const {
        data: { body }
      } = await getHouse({ name: this.value, id })
      this.renderlist = body
      console.log( this.renderlist);
    }
  }
}
</script>

<style scoped lang="less">
.vue_bar {
  background-color: #ccc;
}
h4 {
  font-size: 14px;
  font-weight: 400;
}
</style>
